$('.add').click(function(){
	var version = $().jquery;
  	alert("You are running jQuery version: " + version);
	});


var app = new Vue({
    el: '#app',
    data: {
        allChecked: false,
        tableData: []

    },

    watch: {
        allChecked: function(newValue, oldValue){
            if(newValue){
                this.tableData.map(value => {
                    value.checked = true;
                })
            }else{
                this.tableData.map(value => {
                    value.checked = false;
                })
            }
        }
    },

    created() {
        console.log(1)
        var url = "http://59.110.220.200:5000/api";
        var params = "";
        this.http_get(url)
    },

    methods: {
        onDelete(){
            var arr = [];
            var url = "";
            if(this.allChecked){
                url+="?type=all"
                return this.http_post(url, []);
            }

            this.tableData.map(value => {
                if(value.checked){
                    arr.push(value.id)
                }
            })

            let url = "url";
            this.http_post(url, arr);
        },
        http_post(url, data){
            $.ajax({
                url: url,
                method: 'post',
                data: data,
                success: function(res)  {
                    console.log(res);
                }
            })
        },
        http_get(url, params){
            var that = this;
            console.log($);
            $.ajax({
                url: url,
                method: 'get',
                success: function(res)  {
                    console.log(res)
                    // res.map(value => {
                    //     value.checked = false;
                    // })
                    res.checked = false;
                    that.tableData.push(res);
                }
            })
        }
    }
})
